<%@page pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%String path = request.getContextPath(); %>
<html>
	<head>
	<jsp:include page="../common/init.jsp"></jsp:include>
		<title>用户列表页面</title>
        <link rel="stylesheet" href="<%=path%>/css/fixedTable.css" type="text/css" />
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/javaScript/jquery.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/javaScript/jquery.fixedheadertable.min.js"></script>
		<script type="text/javascript">
		 $(document).ready(function(){
			    $('#listTable').fixedHeaderTable({altClass: 'odd', themeClass: 'fancyTable', autoShow: false });
			    $('#listTable').fixedHeaderTable('show');
         }); 
	   </script>
	</head>
    <script>
var yhbhs ="";//存放多个部门编号;
//验证部门信息checkBoxx是否选中
function checkSCount() 
{
	var intSCount=0;
	yhbhs = "";
	if (document.forms[0].yhbhs!=null)
	{	
		if(document.forms[0].yhbhs.length>1) 
		{
		
			for(i=0;i<document.forms[0].yhbhs.length;i++) 
			{
				if(document.forms[0].yhbhs[i].checked)
				{
					intSCount=intSCount+1;
					yhbhs +=document.forms[0].yhbhs[i].value+",";
				}
			}
			
		} 
		else 
		{
			if(document.forms[0].yhbhs.checked)  
			{
				intSCount=1;
				yhbhs=document.forms[0].yhbhs.value;
			}
		}
	}
	return intSCount;
}
//数据查询;
function doSear(action)
{
	if(isSpecial(document.getElementById("bmmc").value))
	{
		alert("所属部门包含非法字符,请重新输入!");
		document.getElementById("bmmc").focus();
		return false;
	}
	else if(isSpecial(document.getElementById("yhm").value))
	{
		alert("用户名包含非法字符,请重新输入!");
		document.getElementById("yhm").focus();
		return false;
	}
	else if(isSpecial(document.getElementById("xm").value))
	{
		alert("姓名包含非法字符,请重新输入!");
		document.getElementById("xm").focus();
		return false;
	}
	else
	{
		doSearch(action);
	}
}
//添加页面跳转方法
function doAdd()
{
	popPage("createDlyhForm.do",400,500);
}
//删除方法
function doDelete(yhbh)
{
	var action = "removeDlyh.do";
	if(yhbh!="")
	{
		yhbhs="";
		yhbhs=yhbh;
	}
	else
	{
		if(checkSCount()<1)
		{
			alert("请选中要删除的记录!");
			return false;
		}
	}
	document.forms[0].yhbh.value=yhbhs;
	var temp = "";
	var delFlag = 0;
	for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
	{
	     temp=parent.bottomFrame.rightForm.yhbhs.options[j].value;
	     if(temp.endWith("/1"))
	     {
		     temp=","+temp.substring(0,temp.indexOf("/"))+",";
		     if((","+yhbhs+",").indexOf(temp)>-1)
		     {
		         delFlag=1;
		         break;
		     }
	     }
	}
	if(delFlag==1)
	{
	     alert("待授权用户/用户组区存在要删除的用户，\n不能进行删除操作！");
	     return false;
	}
	if(confirm("确定要删除数据吗?"))
	{
		document.forms[0].action=action;
		document.forms[0].submit();
	}	
	else
	{
		return false;
	}
}
function doEdit(yhbh)
{
	var temp = "";
	var editFlag = 0;
	for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
	{
	     temp=parent.bottomFrame.rightForm.yhbhs.options[j].value;
	     if(temp.endWith("/1"))
	     {
		     temp=","+temp.substring(0,temp.indexOf("/"))+",";
		     if((","+yhbh+",").indexOf(temp)>-1)
		     {
		         editFlag=1;
		         break;
		     }
	     }
	}
	if(editFlag==1)
	{
	     alert("待授权用户组区存在要修改的用户，\n不能进行修改操作！");
	     return false;
	}
	else
	{
		popPage('reworkDlyhForm.do?yhbhs='+yhbh,400,500);
	}
}
function doInit(yhbh)
{
  	document.forms[0].yhbh.value=yhbh;
  	action = "initMima.do";
  	if(confirm("确定要进行还原密码操作吗?"))
  	{
  	 document.forms[0].action=action;
	 document.forms[0].submit();
  	}
	else
	{
		return false;
	}
}
//生成功能按钮	
mpmenu1=new mMenu('','doAdd()','script','<%=path%>/images/img_ht_wz_37.gif','62','24','0','100','2');
mpmenu3=new mMenu('','doDelete(\"\")','script','<%=path%>/images/img_ht_wz_41.gif','62','24','0','20','0');
mpmenu4=new mMenu('','doSear(\"listDlyh.do\")','script','<%=path%>/images/img_ht_wz_46.gif','62','24','0','300','0');
//用户授权
function doRight(action)
{
	action+="&tempid=" + Math.random();
	win = window.showModalDialog(action,null,'dialogHeight=650px;dialogWidth=750px;status=no;scroll=no;help=no');
	data=win;
	if(data!=null&&data[0]=='noRight')
	{	
		popPage("createXmlTree.do?yhbhs="+data[1],650,750);	
	}
}
function addrole()         
{    
	alert("只能对用户组授权！");
	return;     
	var estlag = 0 ;
	var outValue="";
	var num = 0;
	if (document.forms[0].yhbhs!=null)
	{
		if(document.forms[0].yhbhs.length>1) 
		{
			for(i=0;i<document.forms[0].yhbhs.length;i++)  
			{
				estlag = 0 ;
				if(document.forms[0].yhbhs[i].checked)         
				{         
					outValue=eval("yhm_"+i+".outerText")+"(用户)";
					estlag = 1;		
					num ++;		         
					//break;         
				} 
				if(estlag==1)
				{
					
					for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
					{         
						if(parent.bottomFrame.rightForm.yhbhs.options[j].text==outValue)         
						{         
							estlag = 0;         
							break;         
						}
					}         
					if(estlag == 1)
					{
					rolecnt = parent.bottomFrame.rightForm.yhbhs.length;         
					rolecnt++;         
					parent.bottomFrame.rightForm.yhbhs.length = rolecnt ;        
					parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].text = outValue;         
					parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].value = document.forms[0].yhbhs[i].value;//+"/"+"1";
					}         
				}
			}
		}
		else
		{
			estlag = 0 ;
			if(document.forms[0].yhbhs.checked)
			{
				outValue=eval("yhm_0.outerText")+"(用户)";
				estlag = 1;	
				num ++;	
			}
			if(estlag==1)
			{
				for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
				{         
					if(parent.bottomFrame.rightForm.yhbhs.options[j].text==outValue)         
					{         
						estlag = 0;         
						break;         
					}
				}         
				if(estlag == 1)
				{
				rolecnt = parent.bottomFrame.rightForm.yhbhs.length;         
				rolecnt++;         
				parent.bottomFrame.rightForm.yhbhs.length = rolecnt ;        
				parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].text = outValue;         
				parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].value = document.forms[0].yhbhs.value;//+"/"+"1";
				}         
			}
		}
	}
	if(num==0)
	{
		alert("请首先选中要授权的用户！");
		return;
	}                
} 
//还原密码操作提示
function initInfo()
{
	var initFlag="<s:property value="urlFlag"/>";
	if(initFlag=="initSuccess")
	{
		alert("还原密码操作成功！");
	}
	else if(initFlag=="initFailure")
	{
	    alert("还原密码操作失败，请重新操作！");
	}
	
}
//全选
function selectAll(){
  var checkAll = document.all("checkbox3").checked;
  var yhbhs = document.getElementsByName("yhbhs");
  for(var i =0; i< yhbhs.length;i++){   
     yhbhs[i].checked = checkAll;
  }
}
//去掉全选状态
function selectNoAll()
{
    var num = 0;
    var len = 0;
    for(i=0;i<document.forms[0].elements.length;i++) 
    {
      if(document.forms[0].elements[i].type == "checkbox"&&document.forms[0].elements[i].name!="checkbox3")
      {
         len++;
         if(document.forms[0].elements[i].checked)
         num++;
      }
    }
    if(num==len&&num>0)
    {
      document.all("checkbox3").checked=true;
    }
    else
    {
       document.all("checkbox3").checked=false;
    }
}
</script>
	<%
		response.setHeader("Cache-Control", "no-store");
		response.setDateHeader("Expires", 0);
		response.setHeader("Pragma", "no-cache");
	%>
	<body onload="initInfo()">
		<s:form action="" method="get">
			<table cellspacing="0" cellpadding="0" class="main_tab1">
				<tr>
					<td colspan="3">
						<table width="100%" border="0" cellspacing="0" cellpadding="0"
							background="<%=path%>/images/img_biaoqian_5.gif">
							<tr>
								<td width="10%">
									<table border="0" cellspacing="0" cellpadding="0"
										class="main_tab1">
										<tr>
											<td width="5">
												<img
													src="<%=path%>/images/img_biaoqian_i_1.gif">
											</td>
											<td align="center" nowrap
												background="<%=path%>/images/img_biaoqian_i_2.gif">
												&nbsp;&nbsp;&nbsp;&nbsp;
												<strong>用户管理</strong>&nbsp;&nbsp;&nbsp;&nbsp;
											</td>
											<td width="5">
												<img
													src="<%=path%>/images/img_biaoqian_i_3.gif">
											</td>
										</tr>
									</table>
								</td>
								<td width="10%">
									<table border="0" cellspacing="0" cellpadding="0"
										class="main_tab1">
										<tr>
											<td width="5">
												<img
													src="<%=path%>/images/img_biaoqian_u_1.gif">
											</td>
											<td align="center" nowrap
												background="<%=path%>/images/img_biaoqian_u_2.gif">
												&nbsp;&nbsp;&nbsp;
												<a href="yhzList.do">用户组管理</a>&nbsp;&nbsp;&nbsp;
											</td>
											<td width="5">
												<img
													src="<%=path%>/images/img_biaoqian_u_4.gif">
											</td>
										</tr>
									</table>
								</td>
								<td width="80%">
									&nbsp;
								</td>
							</tr>
						</TABLE>
					</td>
				</tr>
				<tr>
					<td class="">
						<img src="<%=path%>/images/img_ht_wz_28.gif"
							alt="left" />
					</td>
					<td class="main_tab1_td2">
						<div id="location">
							用户管理
						</div>
						<div id="funbut">
							<SCRIPT>document.write(mwritetodocument());</SCRIPT>
						</div>
					</td>
					<td class="main_tab1_td1">
						<img src="<%=path%>/images/img_ht_wz_32.gif"
							alt="right" />
					</td>
				</tr>
				<tr>
					<td colspan="3" class="main_tab1_td3">
						<div id="mainbg">
							<div class="jiange10"></div>
							<table width="100%" border="0" cellspacing="0" cellpadding="0" class="main_tab3">
								<tr>
									<th width="100">
										<img
											src="<%=path%>/images/img_ht_wz_58.gif"
											alt="查询条件" class="img_01">
										查询条件
									</th>
									<td>
										<table width="100%" border="0" cellspacing="0" cellpadding="0"
											class="main_tab4">
											<tr>
												<th>
													所属部门：
												</th>
												<td>
													<input id="bmmc" name="dlyhBean.bmmc" type="text" size="10"
														maxlength="20"
														value="<s:property  value="dlyhBean.bmmc" />">
												</td>
												<th>
													用户名：
												</th>
												<td>
													<input id="yhm" name="dlyhBean.yhm" type="text" size="10"
														maxlength="20"
														value="<s:property  value="dlyhBean.yhm" />">
												</td>
												<th>
													姓名：
													<s:hidden name="actionId"></s:hidden>
													<input name="yhbh" type="hidden" />
												</th>
												<td>
													<input id="xm" name="dlyhBean.xm" type="text" size="10"
														maxlength="20" value="<s:property  value="dlyhBean.xm" />">
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
							<div class="jiange10"></div>
							<div id="divgyDbxxbList" style="height: 76%; width: 100%; overflow: auto;">
								<table id="listTable" width="100%" border="0" cellspacing="0" cellpadding="0">
								  <thead>
									<tr>
										<th>
											全选
											<input type="checkbox" name="checkbox3" value="1" onclick="selectAll();">
										</th>
										<th>
											操作
										</th>
										<th>
											用户名
										</th>
										<th>
											姓名
										</th>
										<th>
											职务
										</th>
										<th>
											所属部门
										</th>
										<!--<th>
											权限管理
										</th>-->
									</tr>
									</thead>
									<tbody>
									<s:iterator id="dlyhBean" value="dlyhList" status="index">									
										<tr valign="bottom" height="25">
											<td align="center">
												<input type="checkBox" name="yhbhs" onclick="selectNoAll()"
													value="<s:property  value="yhbh" />">
											</td>
											<td>
												<a href="#" onclick="doEdit('<s:property  value="yhbh"/>')">修改</a>
												<a href="#"
													onclick="doDelete('<s:property  value="yhbh" />')">删除</a>
												<a href="#" onclick="doInit('<s:property  value="yhbh" />')">还原密码</a>
												<a href="#"
													onclick="popPage('selYhz.do?yhbhs=<s:property  value="yhbh" />&dlyhBean.yhm=<s:property value="yhm"/>',600,450)">所属组</a>
											</td>
											<td align="left" id="yhm_<s:property  value="#index.index" />">
												<s:property value="yhm" />
											</td>
											<td align="left" title="<s:property  value="xm" />">
													<s:property value="xm" />
											</td>
											<td align="left">
												<s:property value="zw" />
											</td>
											<td align="left" title="<s:property  value="bmmc" />">
												<s:if test="(bmmc+'').length()>14">
													<s:property value="bmmc.substring(0,14)" />...
				                                </s:if>
												<s:else>
													<s:property value="bmmc" />
												</s:else>
											</td>
											<!--<td align="right">
												<a href="#" onclick="doRight('createXmlTree.do?yhbhs=<s:property  value="yhbh" />')">系统权限</a>
												<a href="#" onclick="doRight('<%=path%>/webmanager/qxgl/rightIndex.jsp?yhbhs=<s:property  value="yhbh" />')">功能权限</a>
											</td>-->
										</tr>
									</s:iterator>
									</tbody>
								</table>
							</div>
							<jsp:include page="../common/page.jsp">
			                      <jsp:param value="listDlyh.do" name="doAction"/>
			                 </jsp:include>
						</div>
					</td>
				</tr>
				<tr>
					<td class="main_tab1_td4">
						<img src="<%=path%>/images/img_ht_wz_65.gif"
							alt="left" />
					</td>
					<td class="main_tab1_td5"></td>
					<td class="main_tab1_td4">
						<img src="<%=path%>/images/img_ht_wz_67.gif"
							alt="right" />
					</td>
				</tr>

			</table>
		</s:form>
	</body>
</html>
